package behaviors;

import model.Assets;
import model.Entity;

import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.contacts.ContactPoint;
import org.jbox2d.dynamics.contacts.ContactResult;

// behavior for items that pop when hit with a bullet
public class Balloon extends Behavior {
	public Entity shapeData1, shapeData2;

	@Override
	public void onCollide(ContactPoint arg0) {
		shapeData1 = ((Entity) arg0.shape1.getBody().getUserData());
		shapeData2 = ((Entity) arg0.shape2.getBody().getUserData());

		// pop this object like a balloon if hit by a bullet
		if (shapeData1.isBullet || shapeData2.isBullet) {

			Assets.getInstance().getSound("assets/sfx/pop.wav").play(1, .25f);

			if (shapeData2.isBullet) {
				shapeData1.recycle = true;
			}
			if (shapeData1.isBullet) {
				shapeData2.recycle = true;
			}
		}
	}

	@Override
	public void onRemove(ContactPoint arg0) {
	}

	@Override
	public void onPersist(ContactPoint arg0) {
	}

	@Override
	public void onResult(ContactResult arg0) {
	}

	@Override
	public void update(Body b) {
	}

	@Override
	public void init() {
	}
}
